use strict;
use warnings;

use Test::More tests => 1;

use HTML::FormFu;

my $form = HTML::FormFu->new->auto_id("%n")->element_defaults({
    "Dojo::DropdownDatePicker" => {
        input_format => "dd/MM/yyyy",
        dojo_attributes => {
            displayFormat => "dd/MM/yyyy",
            saveFormat => "dd/MM/yyyy", 
        },
    },
});

$form->element('Dojo::DropdownDatePicker')->name('dp')->value("31/12/2006");

my $xhtml = <<EOF;
<form action="" method="post">
<span class="text dojodropdowndatepicker">
<input name="dp" type="text" value="31/12/2006" id="dp" />
</span>
<script type="text/javascript">
dojo.require("dojo.date.format");
dojo.require("dojo.widget.DropdownDatePicker");
var inputDate = dojo.html.getAttribute( dojo.byId("dp"), "value" );
var formattedDate = dojo.date.parse( inputDate, {datePattern: "dd/MM/yyyy"} );
var dp_dddp = dojo.widget.createWidget(
    "DropdownDatePicker",
    {displayFormat: "dd/MM/yyyy", inputName: "dp", saveFormat: "dd/MM/yyyy"},
    dojo.byId("dp")
);
dp_dddp.setValue( formattedDate );

</script>
</form>
EOF

is( "$form", $xhtml );
